NewRecord = function(type){
	
	var recordPanel = Ext.create('Ext.Panel',{
			id:'record',
		 	frame: true,		 
		 	bodyStyle: {
                background: 'white',
                padding: '20px'
            },
		 	layout: {
                type: 'table',
                columns: 6,
                tableAttrs: {
                    border: 1,
                    cellpadding: 5,
                    cellspacing: 1,
                    width: 660,
                    align: 'center',
                    style: "border:1px solid black;border-collapse:collapse;margin:0 auto;text-align:center;"
                },
                tdAttrs: {
                    width: '90px',
                    //height: '40px',
                    //style: "padding:5px",
                    valign: 'middle',
                    align: 'center',
                }
            },
            defaults: {
                // applied to each contained panel
                xtype: 'label'
            },
            items: [{
            	colspan: 6,
            	text:'指导记录表',
            	style:"font-size:30px",
            	
            },{
            	id:'recordCode',
            	xtype: 'textfield',
            	hidden:true
            },{
            	
                text: '指导人'
            }, {
                id:'recordteacherName',
                xtype: 'textfield',
                //fieldCls: 'textfieldBorder',
                readOnly:true,
                width:130
            },{
            	
                text: '学院'
            }, {
                id:'recordacadmy',
                xtype: 'textfield',
                //fieldCls: 'textfieldBorder',
                readOnly:true,
                width:130
            },{
            	
                text: '专业'
            }, {
                id:'recordprofessional',
                xtype: 'textfield',
                //fieldCls: 'textfieldBorder',
                readOnly:true,
                width:130
            },, {
                text: '指导时间',
            },
        {
            id:'recordguideTime',
            xtype: 'datefield',
           // fieldCls: 'textfieldBorder',
            width:130,
            format: 'Y-m-d',
            editable: false,
            allowBlank: false,
            blankText: '请选择指导日期',
        }
        , {
            text: '指导形式'
        },
            {
        	 id:'recordguideType',
        	 xtype: 'textfield',
            // fieldCls: 'textfieldBorder',
             width:130
            },
            {
                text: '参加人数',
            },
            {
            	id:'recordstudentNumber', 
            	xtype: 'textfield',
                // fieldCls: 'textfieldBorder',
                 width:130
            },{
            	colspan: 1,
            	text:'指导课题',
            	
            },
            {
            	id:'recordguideTitle',
            	colspan: 5,
            	xtype:'textfield',
            	width:460,
        		
        		//fieldCls: 'textfieldBorder',           	
            },
            {
            	colspan: 1,
            	text:'指导内容',
            	
            },{
            	id:'recordguideText',
            	colspan: 5,
            	xtype:'htmleditor',
            	width:500,
        		height:200,
        		//fieldCls: 'textfieldBorder',           	
            },{
            	colspan: 1,
            	text:'指导总结',
            	
            },{
            	id:'recordguideSummary',
            	colspan: 5,
            	xtype:'htmleditor',
            	width:500,
        		height:200,
        		//fieldCls: 'textfieldBorder',
            },{
            	colspan: 1,
            	text:'指导人签名：',
            },{
            	colspan: 1,
            },{
            	colspan: 1,
            	text:'学生签名：',
            },{
            	colspan: 3,
            }],
            buttons:[{
           	 text:'保存',
             handler: sumbit,
            },{
                 text:'打印预览',
                 handler: prn1_preview,
                
            }],
            buttonAlign : "center",
            afterrender: loadRecordMessage()
	});
	function loadRecordMessage(){
		
		if(type =="-1"){
			 Ext.Ajax.request( {
			    	url : "searchTeacherAction.action", 
			    	params : {
			    		teacherId : teacherId,
			    	}, //参数
			    	success : function(response, option) {
			    		var obj = Ext.decode(response.responseText);
			    		Ext.getCmp("recordteacherName").setValue(obj.list[0].teacherName);
			    		Ext.getCmp('recordacadmy').setValue(obj.list[0].academy.valueName);
			    		Ext.getCmp('recordprofessional').setValue(obj.list[0].professional.valueName);
			    	},
			    	failure : function(response, option) {
			    		Ext.Msg.alert("失败", "系统错误");
			    	}
			    	});
		}
		else{
			Ext.Ajax.request( {
		    	url : "selectGuideRecodeByCodeAction.action", 
		    	params : {
		    		recordCode : type,
		    	}, //参数
		    	success : function(response, option) {
		    		var obj = Ext.decode(response.responseText).guideRecordPojo;
		    		Ext.getCmp("recordCode").setValue(obj.recordCode);
		    		Ext.getCmp("recordteacherName").setValue(obj.teacherName);
		    		Ext.getCmp('recordacadmy').setValue(obj.acadmy);
		    		Ext.getCmp('recordprofessional').setValue(obj.professional);
		    		Ext.getCmp('recordguideTime').setValue(obj.guideTime);
		    		Ext.getCmp('recordguideType').setValue(obj.guideType);
		    		Ext.getCmp('recordstudentNumber').setValue(obj.studentNumber);
		    		Ext.getCmp('recordguideTitle').setValue(obj.guideTitle);
		    		Ext.getCmp('recordguideText').setValue(obj.guideText);
		    		Ext.getCmp('recordguideSummary').setValue(obj.guideSummary);
		    	},
		    	failure : function(response, option) {
		    		Ext.Msg.alert("失败", "系统错误");
		    	}
		    	});
	
		}
	}
	
	function prn1_preview() { 
	    CreateOneFormPage(); 
	  };
	function CreateOneFormPage()
	  {
		//Ext.Msg.alert("提示","jinru");
	   //LODOP=getLodop(document.getElementById('LODOP_OB'),document.getElementById('LODOP_EM'));
		var LODOP=getLodop(); 
	 /*  try{ 
	 Ext.Msg.alert("提示",LODOP.VERSION);
			if (LODOP.VERSION) {
				 if (LODOP.CVERSION)
					 Ext.Msg.alert("当前有C-Lodop云打印可用!\n C-Lodop版本:"+LODOP.CVERSION+"(内含Lodop"+LODOP.VERSION+")"); 
				 else
					 Ext.Msg. alert("本机已成功安装了Lodop控件！\n 版本号:"+LODOP.VERSION); 
			}else{
				Ext.Msg.alert("提示","你还没有安装dolop打印插件");
				return;
			}
		 }catch(err){ 
		 }*/
	  // Ext.Msg.alert("提示","1");	
		LODOP.PRINT_INIT("打印控件功能演示_Lodop功能_表单一");
	  // LODOP.SET_PRINT_STYLE("FontSize",15);
	  // LODOP.SET_PRINT_STYLE("Bold",1);
	   
	  // LODOP.ADD_PRINT_HTM(0,0,660,900,document.getElementById("record").innerHTML);
	   var teacherName = Ext.getCmp('recordteacherName').getValue();
	   var acadmy = Ext.getCmp('recordacadmy').getValue();
	   var professional = Ext.getCmp('recordprofessional').getValue();
	   var guideTime = Ext.Date.format(new Date(Ext.getCmp('recordguideTime').getValue()),'Y-m-d'); 
	   var guideType = Ext.getCmp('recordguideType').getValue();
	   var studentNumber = Ext.getCmp('recordstudentNumber').getValue();
	   var guideTitle = Ext.getCmp('recordguideTitle').getValue();
	   var guideText = Ext.getCmp('recordguideText').getValue();
	   var guideSummary = Ext.getCmp('recordguideSummary').getValue();
	   LODOP.ADD_PRINT_HTM(50,100,660,900,
			   "<table width='90%' border='1' cellpadding='0' cellspacing='0' algin='center'>" +
			   "<tr><td colspan='6' align='center'><h2>导师指导记录表<h2></td></tr>"+
			   "<tr><td width='14%' height='40'>指导人：</td><td width='20%'>"+teacherName+"</td>" +
			   		"<td width='13%'>学院:</td><td width='20%'>"+acadmy+"</td>" +
			   		"<td width='13%'>专业:</td><td>"+professional+"</td>" +
			   "</tr>" +
			   "<tr><td width='14%' height='40'>指导时间：</td><td width='20%'>"+guideTime+"</td>" +
			   		"<td width='13%'>指导形式:</td><td width='20%'>"+guideType+"</td>" +
			   		"<td width='13%'>参考人数:</td><td>"+studentNumber+"</td>" +
			   "</tr>" +
			   "<tr><td width='14%' height='50'>指导课题：</td><td colspan='5'>"+guideTitle+"</td></tr>" +
			   "<tr><td width='14%' height='250'>指导内容：</td><td colspan='5'>"+guideText+"</td></tr>" +
	   		   "<tr><td width:'14%' height='250'>指导总结：</td><td colspan='5'>"+guideSummary+"</td></tr>+" +
	   		   "<tr><td width:'14%' height='40'>导师签字：</td><td></td><td width:'14%'>学生签字：</td><td colspan='3'></td></tr></table>");
	   
	   LODOP.PREVIEW();	   	 
	  };
	  
	  function sumbit() {
	    	var jsonString="{'teacherName':"+"'"+Ext.getCmp('recordteacherName').getValue()+"'"
	    	+",'recordCode':"+"'"+Ext.getCmp('recordCode').getValue()+"'"
	    	+",'acadmy':"+"'"+Ext.getCmp('recordacadmy').getValue()+"'"
	    	+",'professional':"+"'"+Ext.getCmp('recordprofessional').getValue()+"'"
	    	+",'guideTime':"+"'"+Ext.Date.format(new Date(Ext.getCmp('recordguideTime').getValue()),'Y-m-d')+"'"
	    	+",'guideType':"+"'"+Ext.getCmp('recordguideType').getValue()+"'"
	    	+",'studentNumber':"+"'"+Ext.getCmp('recordstudentNumber').getValue()+"'"
	    	+",'guideTitle':"+"'"+Ext.getCmp('recordguideTitle').getValue()+"'"
	    	+",'guideText':"+"'"+Ext.getCmp('recordguideText').getValue()+"'"
	    	+",'guideSummary':"+"'"+Ext.getCmp('recordguideSummary').getValue()+"'"
	    	+"}";
	    	
	    	Ext.Ajax.request( {
	    		url : "addGuideRecodeAction.action", 
	    		params : {
	    			AddJson : jsonString,
	    		}, //参数
	    		success : function(response, option) {
	    			var obj = Ext.decode(response.responseText);
	    			if(obj.success){
	    				Ext.Msg.alert("提示", "保存成功");
	    			}else{
	    				Ext.Msg.alert("提示", "保存失败");
	    			}
	    			
	    		},
	    		failure : function(response, option) {
	    			Ext.Msg.alert("提示", "保存失败");
	    		}
	    		});
	    		
	    }
	return recordPanel;
};

